package com.qlk.odcinterface.service.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.qlk.odcinterface.domain.PmsFullCutItem;
import com.qlk.odcinterface.domain.query.PmsFullCutItemQuery;
import com.qlk.odcinterface.manager.PmsFullCutItemManager;
import com.qlk.odcinterface.service.PmsFullCutItemService;
import com.qlk.odcinterface.utils.exceptions.ExistedException;
import com.qlk.common.utils.page.PageUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.perf4j.aop.Profiled;
 
/**
 * PmsFullCutItemService接口的实现类
 * 
 * @author zhaoyanan
 * @version 2016-4-14 13:22:58
 * 
 */
@Service
public class PmsFullCutItemServiceImpl implements PmsFullCutItemService {

    /** LOG */
    private static final Log LOG = LogFactory.getLog(PmsFullCutItemServiceImpl.class);

    @Autowired
    private PmsFullCutItemManager pmsFullCutItemManager;

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.batchInsert")
    public boolean insert(List<PmsFullCutItem> pmsFullCutItemList) {
        boolean resultFlag = false;
        try {
            if (CollectionUtils.isNotEmpty(pmsFullCutItemList)) {
                resultFlag = pmsFullCutItemManager.insert(pmsFullCutItemList);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#batchInsert failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#batchInsert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.insert")
    public boolean insert(PmsFullCutItem pmsFullCutItem) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutItem) {
                if (pmsFullCutItemManager.exist(pmsFullCutItem)) {
                    throw new ExistedException();
                }
                resultFlag = pmsFullCutItemManager.insert(pmsFullCutItem);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#insert failed, param is illegal.");
            }
        } catch (ExistedException e) {
            LOG.warn("PmsFullCutItemServiceImpl#insert failed, pmsFullCutItem has existed.");
            throw e;
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#insert has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.update")
    public boolean update(PmsFullCutItem pmsFullCutItem) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutItem && null != pmsFullCutItem.getId()) {
                resultFlag = pmsFullCutItemManager.update(pmsFullCutItem);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#update failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#update has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.queryPmsFullCutItemList")
    public List<PmsFullCutItem> queryPmsFullCutItemList(PmsFullCutItemQuery queryBean) {
        List<PmsFullCutItem> pmsFullCutItemList = null;
        try {
            pmsFullCutItemList = pmsFullCutItemManager.queryPmsFullCutItemList(queryBean);
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#queryPmsFullCutItemList has error.", e);
        }
        return pmsFullCutItemList;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.queryPmsFullCutItemListWithPage")
    public List<PmsFullCutItem> queryPmsFullCutItemListWithPage(PmsFullCutItemQuery queryBean, PageUtil pageUtil) {
        List<PmsFullCutItem> pmsFullCutItemList = null;
        try {
            pmsFullCutItemList = pmsFullCutItemManager.queryPmsFullCutItemListWithPage(queryBean, pageUtil);
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#queryPmsFullCutItemListWithPage has error.", e);
        }
        return pmsFullCutItemList;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.delete")
    public boolean delete(PmsFullCutItem pmsFullCutItem) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutItem && null != pmsFullCutItem.getId()) {
                resultFlag = pmsFullCutItemManager.delete(pmsFullCutItem);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#delete param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#delete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.batchDelete")
    public boolean delete(PmsFullCutItem[] pmsFullCutItems) {
        boolean resultFlag = false;
        try {
            if (null != pmsFullCutItems && pmsFullCutItems.length > 0) {
                resultFlag = pmsFullCutItemManager.delete(pmsFullCutItems);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#batchDelete failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#batchDelete has error.", e);
        }
        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    @Profiled(tag = "PmsFullCutItemService.getPmsFullCutItemById")
    public PmsFullCutItem getPmsFullCutItemById(Long id) {
        PmsFullCutItem pmsFullCutItem = null;
        try {
            if (null != id) {
                pmsFullCutItem = pmsFullCutItemManager.getPmsFullCutItemById(id);
            } else {
                LOG.warn("PmsFullCutItemServiceImpl#getPmsFullCutItemById failed, param is illegal.");
            }
        } catch (Exception e) {
            LOG.error("PmsFullCutItemServiceImpl#getPmsFullCutItemById has error.", e);
        }
        return pmsFullCutItem;
    }
}

